// 元组的定义
let x: [string, number]
x = ['hello', 10]
// x = ['hello', 10, 10]
// x = [10, 'hello']

// 元组类型的解构赋值
let employee: [number, string] = [1, 'student']
let [id, username] = employee
console.log(id, username) // 1 student

// 元组类型的可选元素
let optionalTuple: [string, boolean?]
optionalTuple = ['well', true]
console.log(optionalTuple) // [ 'well', true ]
optionalTuple = ['well']
console.log(optionalTuple) // [ 'well' ]

// 元组类型的剩余参数
type RestTupleType = [number, ...string[]]
let restTuple: RestTupleType = [666, "Semlinker", "Kakuqo", "Lolo"]
console.log(restTuple[0]) // 666
console.log(restTuple[1]) // Semlinker

// 只读的元组类型
const point: readonly [number, number] = [10, 10]
// point[0] = 1 error